<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>src\export.js - GIAnT API</title>
    <link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
    <link rel="icon" href="../assets/favicon.ico">
    <script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
</head>
<body class="yui3-skin-sam">

<div id="doc">
    <div id="hd" class="yui3-g header">
        <div class="yui3-u-3-4">
                <h1><img src="../assets/css/logo.png" title="GIAnT API" width="117" height="52"></h1>
        </div>
        <div class="yui3-u-1-4 version">
            <em>API Docs for: 1.0.0</em>
        </div>
    </div>
    <div id="bd" class="yui3-g">

        <div class="yui3-u-1-4">
            <div id="docs-sidebar" class="sidebar apidocs">
                <div id="api-list">
                    <h2 class="off-left">APIs</h2>
                    <div id="api-tabview" class="tabview">
                        <ul class="tabs">
                            <li><a href="#api-classes">Classes</a></li>
                            <li><a href="#api-modules">Modules</a></li>
                        </ul>
                
                        <div id="api-tabview-filter">
                            <input type="search" id="api-filter" placeholder="Type to filter APIs">
                        </div>
                
                        <div id="api-tabview-panel">
                            <ul id="api-classes" class="apis classes">
                                <li><a href="../classes/Atom.html">Atom</a></li>
                                <li><a href="../classes/Codec.html">Codec</a></li>
                                <li><a href="../classes/Constraints.html">Constraints</a></li>
                                <li><a href="../classes/Database.html">Database</a></li>
                                <li><a href="../classes/Exif.html">Exif</a></li>
                                <li><a href="../classes/Export.html">Export</a></li>
                                <li><a href="../classes/Heatmap.html">Heatmap</a></li>
                                <li><a href="../classes/Server.html">Server</a></li>
                                <li><a href="../classes/Settings.html">Settings</a></li>
                                <li><a href="../classes/Utils.html">Utils</a></li>
                            </ul>
                
                
                            <ul id="api-modules" class="apis modules">
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="yui3-u-3-4">
                <div id="api-options">
                    Show:
                    <label for="api-show-inherited">
                        <input type="checkbox" id="api-show-inherited" checked>
                        Inherited
                    </label>
            
                    <label for="api-show-protected">
                        <input type="checkbox" id="api-show-protected">
                        Protected
                    </label>
            
                    <label for="api-show-private">
                        <input type="checkbox" id="api-show-private">
                        Private
                    </label>
                    <label for="api-show-deprecated">
                        <input type="checkbox" id="api-show-deprecated">
                        Deprecated
                    </label>
            
                </div>
            
            <div class="apidocs">
                <div id="docs-main">
                    <div class="content">
<h1 class="file-heading">File: src\export.js</h1>

<div class="file">
    <pre class="code prettyprint linenums">
/**
 * Export the neo4j data to sql or csv
 *
 *      Tables
 *          - Nodes
 *          - Edges
 *          - NodeProperties
 *          - EdgeProperties
 *
 *
 *      1) stream the data into temporary files
 *      2) make the files downloadable for the client
 *      3) delete the temporary files
 *
 *
 *      CREATE TABLE IF NOT EXISTS Node (
 *      Node_ID INTEGER PRIMARY KEY AUTOINCREMENT,
 *      tokenType TEXT,
 *      groupType TEXT
 *      );
 *
 *      CREATE TABLE IF NOT EXISTS Relation (
 *      Relation_ID INTEGER PRIMARY KEY AUTOINCREMENT,
 *      SourceNode_ID INTEGER,
 *      TargetNode_ID INTEGER,
 *      relationType TEXT
 *      );
 *
 *      CREATE TABLE IF NOT EXISTS NodeProperties (
 *      NodeProperties_ID INTEGER PRIMARY KEY AUTOINCREMENT,
 *      key TEXT,
 *      value TEXT,
 *      Node_ID INTEGER
 *      );
 *
 *      CREATE TABLE IF NOT EXISTS RelationProperties (
 *      RelationProperties_ID INTEGER PRIMARY KEY AUTOINCREMENT,
 *      key TEXT,
 *      value TEXT
 *      );
 *
 * @class Export
 */
var Export = Export || {};


var log = require(&#x27;electron-log&#x27;);
var fs = require(&#x27;fs&#x27;);
var path = require(&#x27;path&#x27;);
var zlib = require(&#x27;zlib&#x27;);
var archiver = require(&#x27;archiver&#x27;);
var database = require(&#x27;./database&#x27;);




/**
 * The target folder where the exports are stored
 *
 * @property to_folder
 * @type {string}
 * @default path.join(__dirname, &#x27;..&#x27;, &#x27;media&#x27;, &#x27;export&#x27;)
 */
Export.to_folder = path.join(__dirname, &#x27;..&#x27;, &#x27;media&#x27;, &#x27;export&#x27;);

/**
* Get the current time as POSIX time as a string
 *
* @method _get_time
* @return {string}
*/
Export._get_time = function () {
    var d = new Date();
    var upload_date = Math.round(d.getTime());
    return upload_date + &#x27;&#x27;;
};

/**
 * Writes sql code into the given write_stream
 *
 * Starts with the SQL Table creation and then adds all nodes
 *
 * @method _nodes_to_sql
 * @param write_stream {WriteStream}
 * @return {Promise}
 */
Export._nodes_to_sql = function (write_stream) {
    return new Promise(function (resolve, reject) {
        try {
            var session = database._get_session();
            write_stream.write(
                &#x27;CREATE TABLE IF NOT EXISTS Nodes ( \n&#x27; +
                &#x27;Node_ID INTEGER PRIMARY KEY, \n&#x27; +
                &#x27;value TEXT, \n&#x27; +
                &#x27;tokenType TEXT, \n&#x27; +
                &#x27;groupType TEXT \n&#x27; +
                &#x27;); \n\n&#x27;
            );
        } catch (e) {
            return reject(e);
        }

        session.run(&quot;MATCH (n) RETURN ID(n) as ident, n.value as value, n.tokenType as tokenType, n.groupType as groupType;&quot;)
            .subscribe({
                    onNext: function (record) {
                        write_stream.write(&#x27;INSERT INTO Nodes (Node_ID, value, tokenType, groupType) VALUES (&#x27;);
                        write_stream.write(record.get(&#x27;ident&#x27;).toString() + &#x27;, &#x27;);
                        write_stream.write((record.get(&#x27;value&#x27;) ? &#x27;&quot;&#x27; + encodeURIComponent(record.get(&#x27;value&#x27;)) + &#x27;&quot;&#x27; : &#x27;NULL&#x27;) + &#x27;, &#x27;);
                        write_stream.write((record.get(&#x27;tokenType&#x27;) ? &#x27;&quot;&#x27; + encodeURIComponent(record.get(&#x27;tokenType&#x27;)) + &#x27;&quot;&#x27; : &#x27;NULL&#x27;) + &#x27;, &#x27;);
                        write_stream.write((record.get(&#x27;groupType&#x27;) ? &#x27;&quot;&#x27; + encodeURIComponent(record.get(&#x27;groupType&#x27;)) + &#x27;&quot;&#x27; : &#x27;NULL&#x27;) + &#x27;);\n  &#x27;);
                    },
                    onCompleted: function () {
                        session.close();
                        return resolve();
                    },
                    onError: function (error) {
                        log.error(error);
                        reject();
                    }
                }
            );
    });
};

/**
 * Writes sql code into the given write_stream
 *
 * Starts with the SQL Table creation for relations and then adds all relations
 *
 * @method _relations_to_sql
 * @param write_stream {WriteStream}
 * @return {Promise}
 */
Export._relations_to_sql = function (write_stream) {
    return new Promise(function (resolve, reject) {
        try {
            var session = database._get_session();
            write_stream.write(
                &#x27;\nCREATE TABLE IF NOT EXISTS Relations ( \n&#x27; +
                &#x27;Relation_ID INTEGER PRIMARY KEY, \n&#x27; +
                &#x27;relationType TEXT, \n&#x27; +
                &#x27;SourceNode_ID INTEGER REFERENCES Nodes (Node_ID), \n&#x27; +
                &#x27;TargetNode_ID INTEGER REFERENCES Nodes (Node_ID)\n&#x27; +
                &#x27;); \n\n&#x27;
            );
        } catch (e) {
            return reject(e);
        }

        session.run(&quot;MATCH ()-[r]-() RETURN DISTINCT ID(r) as ident, TYPE(r) as type, ID(STARTNODE(r)) as origin, ID(ENDNODE(r)) as target;&quot;)
            .subscribe({
                    onNext: function (record) {
                        write_stream.write(&#x27;INSERT INTO Relations (Relation_ID, relationType, SourceNode_ID, TargetNode_ID) VALUES (&#x27;);
                        write_stream.write(record.get(&#x27;ident&#x27;).toString() + &#x27;, &#x27;);
                        write_stream.write((record.get(&#x27;type&#x27;) ? &#x27;&quot;&#x27; + encodeURIComponent(record.get(&#x27;type&#x27;)) + &#x27;&quot;&#x27; : &#x27;NULL&#x27;) + &#x27;, &#x27;);
                        write_stream.write(record.get(&#x27;origin&#x27;).toString() + &#x27;, &#x27;);
                        write_stream.write(record.get(&#x27;target&#x27;).toString() + &#x27;); \n&#x27;);
                    },
                    onCompleted: function () {
                        session.close();
                        return resolve();
                    },
                    onError: function (error) {
                        log.error(error);
                        reject();
                    }
                }
            );
    });
};

/**
 * Writes sql code into the given write_stream
 *
 * Starts with the SQL Table creation for relation properties and then adds all properties
 *
 * @method _relation_properties_to_sql
 * @param write_stream {WriteStream}
 * @return {Promise}
 */
Export._relation_properties_to_sql = function (write_stream) {
    return new Promise(function (resolve, reject) {
        try {
            var session = database._get_session();
            write_stream.write(
                &#x27;\nCREATE TABLE IF NOT EXISTS RelationProperties ( \n&#x27; +
                &#x27;RelationProperty_ID INTEGER PRIMARY KEY AUTOINCREMENT, \n&#x27; +
                &#x27;Relation_ID INTEGER REFERENCES Relations, \n&#x27; +
                &#x27;key TEXT, \n&#x27; +
                &#x27;value TEXT \n&#x27; +
                &#x27;); \n\n&#x27;
            );
        } catch (e) {
            return reject(e);
        }

        session.run(&quot;Match ()-[n]-() return DISTINCT ID(n) as ident, properties(n) as props;&quot;)
            .subscribe({
                    onNext: function (record) {
                        var props = record.get(&#x27;props&#x27;);
                        Object.keys(props).forEach(function(key) {
                            var value = props[key];
                            write_stream.write(&#x27;INSERT INTO RelationProperties (Relation_ID, key, value) VALUES (&#x27;);
                             write_stream.write(record.get(&#x27;ident&#x27;).toString() + &#x27;, &#x27;);
                             write_stream.write((key ? &#x27;&quot;&#x27; + encodeURIComponent(key) + &#x27;&quot;&#x27; :  &#x27;NULL&#x27;) + &#x27;, &#x27;);
                             write_stream.write((value ? &#x27;&quot;&#x27; + encodeURIComponent(value) + &#x27;&quot;&#x27; :  &#x27;NULL&#x27;) + &#x27;); \n&#x27;);
                        });
                    },
                    onCompleted: function () {
                        session.close();
                        return resolve();
                    },
                    onError: function (error) {
                        log.error(error);
                        reject();
                    }
                }
            );
    });
};

/**
 * Writes sql code into the given write_stream
 *
 * Starts with the SQL Table creation for node properties and then adds all properties
 *
 * @method _node_properties_to_sql
 * @param write_stream {WriteStream}
 * @return {Promise}
 */
Export._node_properties_to_sql = function (write_stream) {
    return new Promise(function (resolve, reject) {
        try {
            var session = database._get_session();
            write_stream.write(
                &#x27;\nCREATE TABLE IF NOT EXISTS NodeProperties ( \n&#x27; +
                &#x27;NodeProperty_ID INTEGER PRIMARY KEY AUTOINCREMENT, \n&#x27; +
                &#x27;Node_ID INTEGER REFERENCES Nodes, \n&#x27; +
                &#x27;key TEXT, \n&#x27; +
                &#x27;value TEXT \n&#x27; +
                &#x27;); \n\n&#x27;
            );
        } catch (e) {
            return reject(e);
        }

        session.run(&quot;Match (n) return DISTINCT ID(n) as ident, properties(n) as props;&quot;)
            .subscribe({
                    onNext: function (record) {
                        var props = record.get(&#x27;props&#x27;);
                        Object.keys(props).forEach(function(key) {
                            var value = props[key];
                            write_stream.write(&#x27;INSERT INTO NodeProperties (Node_ID, key, value) VALUES (&#x27;);
                             write_stream.write(record.get(&#x27;ident&#x27;).toString() + &#x27;, &#x27;);
                             write_stream.write((key ? &#x27;&quot;&#x27; + encodeURIComponent(key) + &#x27;&quot;&#x27; :  &#x27;NULL&#x27;) + &#x27;, &#x27;);
                             write_stream.write((value ? &#x27;&quot;&#x27; + encodeURIComponent(value) + &#x27;&quot;&#x27; :  &#x27;NULL&#x27;) + &#x27;); \n&#x27;);
                        });
                    },
                    onCompleted: function () {
                        session.close();
                        return resolve();
                    },
                    onError: function (error) {
                        log.error(error);
                        reject();
                    }
                }
            );
    });
};

/**
 * Writes csv into the given write_stream
 *
 * Starts with the CSV Table header and then adds all nodes line by line
 *
 * @method _nodes_to_csv
 * @param write_stream {WriteStream}
 * @return {Promise}
 */
Export._nodes_to_csv = function (write_stream) {
    return new Promise(function (resolve, reject) {
        try {
            var session = database._get_session();
            write_stream.write(&#x27;Node_ID,value,tokenType,groupType\n&#x27;);
        } catch (e) {
            return reject(e);
        }

        session.run(&quot;MATCH (n) RETURN ID(n) as ident, n.value as value, n.tokenType as tokenType, n.groupType as groupType;&quot;)
            .subscribe({
                    onNext: function (record) {
                        write_stream.write(record.get(&#x27;ident&#x27;).toString() + &#x27;,&#x27;);
                        write_stream.write((record.get(&#x27;value&#x27;) ? &#x27;&quot;&#x27; + encodeURIComponent(record.get(&#x27;value&#x27;)) + &#x27;&quot;&#x27; : &#x27;NULL&#x27;) + &#x27;,&#x27;);
                        write_stream.write((record.get(&#x27;tokenType&#x27;) ? &#x27;&quot;&#x27; + encodeURIComponent(record.get(&#x27;tokenType&#x27;)) + &#x27;&quot;&#x27; : &#x27;NULL&#x27;) + &#x27;,&#x27;);
                        write_stream.write((record.get(&#x27;groupType&#x27;) ? &#x27;&quot;&#x27; + encodeURIComponent(record.get(&#x27;groupType&#x27;)) + &#x27;&quot;&#x27; : &#x27;NULL&#x27;) + &#x27;\n&#x27;);
                    },
                    onCompleted: function () {
                        session.close();
                        return resolve();
                    },
                    onError: function (error) {
                        log.error(error);
                        reject();
                    }
                }
            );
    });
};

/**
 * Writes csv into the given write_stream
 *
 * Starts with the CSV Table header and then adds all relations line by line
 *
 * @method _relations_to_csv
 * @param write_stream {WriteStream}
 * @return {Promise}
 */
Export._relations_to_csv = function (write_stream) {
    return new Promise(function (resolve, reject) {
        try {
            var session = database._get_session();
            write_stream.write(&#x27;Relation_ID,relationType,SourceNode_ID,TargetNode_ID\n&#x27;);
        } catch (e) {
            return reject(e);
        }

        session.run(&quot;MATCH ()-[r]-() RETURN DISTINCT ID(r) as ident, TYPE(r) as type, ID(STARTNODE(r)) as origin, ID(ENDNODE(r)) as target;&quot;)
            .subscribe({
                    onNext: function (record) {
                        write_stream.write(record.get(&#x27;ident&#x27;).toString() + &#x27;,&#x27;);
                        write_stream.write((record.get(&#x27;type&#x27;) ? &#x27;&quot;&#x27; + encodeURIComponent(record.get(&#x27;type&#x27;)) + &#x27;&quot;&#x27; : &#x27;NULL&#x27;) + &#x27;,&#x27;);
                        write_stream.write(record.get(&#x27;origin&#x27;).toString() + &#x27;,&#x27;);
                        write_stream.write(record.get(&#x27;target&#x27;).toString() + &#x27;\n&#x27;);
                    },
                    onCompleted: function () {
                        session.close();
                        return resolve();
                    },
                    onError: function (error) {
                        log.error(error);
                        reject();
                    }
                }
            );
    });
};

/**
 * Writes csv into the given write_stream
 *
 * Starts with the CSV Table header and then adds all relation_properties line by line
 *
 * @method _relation_properties_to_csv
 * @param write_stream {WriteStream}
 * @return {Promise}
 */
Export._relation_properties_to_csv = function (write_stream) {
    return new Promise(function (resolve, reject) {
        try {
            var session = database._get_session();
            write_stream.write(&#x27;Relation_ID,key,value\n&#x27;);
        } catch (e) {
            return reject(e);
        }

        session.run(&quot;Match ()-[n]-() return DISTINCT ID(n) as ident, properties(n) as props;&quot;)
            .subscribe({
                    onNext: function (record) {
                        var props = record.get(&#x27;props&#x27;);
                        Object.keys(props).forEach(function(key) {
                            var value = props[key];
                             write_stream.write(record.get(&#x27;ident&#x27;).toString() + &#x27;,&#x27;);
                             write_stream.write((key ? &#x27;&quot;&#x27; + encodeURIComponent(key) + &#x27;&quot;&#x27; :  &#x27;NULL&#x27;) + &#x27;,&#x27;);
                             write_stream.write((value ? &#x27;&quot;&#x27; + encodeURIComponent(value) + &#x27;&quot;&#x27; :  &#x27;NULL&#x27;) + &#x27;\n&#x27;);
                        });
                    },
                    onCompleted: function () {
                        session.close();
                        return resolve();
                    },
                    onError: function (error) {
                        log.error(error);
                        reject();
                    }
                }
            );
    });
};

/**
 * Writes csv into the given write_stream
 *
 * Starts with the CSV Table header and then adds all _node_properties_to_csv line by line
 *
 * @method _node_properties_to_csv
 * @param write_stream {WriteStream}
 * @return {Promise}
 */
Export._node_properties_to_csv = function (write_stream) {
    return new Promise(function (resolve, reject) {
        try {
            var session = database._get_session();
            write_stream.write(&#x27;Node_ID,key,value\n&#x27;);
        } catch (e) {
            return reject(e);
        }

        session.run(&quot;Match (n) return DISTINCT ID(n) as ident, properties(n) as props;&quot;)
            .subscribe({
                    onNext: function (record) {
                        var props = record.get(&#x27;props&#x27;);
                        Object.keys(props).forEach(function(key) {
                            var value = props[key];
                             write_stream.write(record.get(&#x27;ident&#x27;).toString() + &#x27;,&#x27;);
                             write_stream.write((key ? &#x27;&quot;&#x27; + encodeURIComponent(key) + &#x27;&quot;&#x27; :  &#x27;NULL&#x27;) + &#x27;,&#x27;);
                             write_stream.write((value ? &#x27;&quot;&#x27; + encodeURIComponent(value) + &#x27;&quot;&#x27; :  &#x27;NULL&#x27;) + &#x27;\n&#x27;);
                        });
                    },
                    onCompleted: function () {
                        session.close();
                        return resolve();
                    },
                    onError: function (error) {
                        log.error(error);
                        reject();
                    }
                }
            );
    });
};

/**
 * Creates a zipped SQL file containing all of the SQL creation and insertion statements for the DB
 * The file is stored in the to_folder of Export
 *
 *
 * @method to_sql
 * @return {Promise}
 */
Export.to_sql = function () {
    return new Promise(function (resolve, reject) {
        try {
            var time_stamp = Export._get_time();
            var file_name = &#x27;sql-&#x27; + time_stamp + &#x27;.sql&#x27;;
            var file_path = path.join(Export.to_folder, file_name);
            var wstream = fs.createWriteStream(file_path);
            return Export._nodes_to_sql(wstream).then(function (data) {
                return Export._relations_to_sql(wstream).then(function (data) {
                    return Export._relation_properties_to_sql(wstream).then(function (data) {
                        return Export._node_properties_to_sql(wstream).then(function(data){
                            wstream.end();
                            var output_path = path.join(Export.to_folder, &#x27;sql-&#x27; + time_stamp + &#x27;.zip&#x27;);

                            var output = fs.createWriteStream(output_path);
                            var archive = archiver(&#x27;zip&#x27;, {
                                gzip: true,
                                zlib: { level: 9 }
                            });

                            archive.on(&#x27;error&#x27;, function(err) {
                              return reject(err);
                            });

                            // pipe archive data to the output file
                            archive.pipe(output);

                            // append files
                            [file_path].forEach(function(file_path){
                                archive.file(file_path, {name: path.basename(file_path)});
                            });
                            // finalize
                            archive.finalize();

                            output.on(&quot;close&quot;, function(){
                                fs.unlinkSync(file_path);
                                resolve(output_path);
                            });
                        }).catch(function(err){
                            wstream.end();
                            reject(err);
                        });

                    }).catch(function (err) {
                        wstream.end();
                        reject(err);
                    });

                }).catch(function (err) {
                    wstream.end();
                    reject(err);
                });
            }).catch(function (err) {
                wstream.end();
                reject(err);
            });
        } catch (e) {
            reject(e);
        }
    });
};

/**
 * Creates a zipped dir containing four files necessary to reassemble the GraphDB&#x27;s storage
 * The file is stored in the to_folder of Export
 *
 *
 * @method to_csv
 * @return {Promise}
 */
Export.to_csv = function () {
    var time_stamp = Export._get_time()
    return new Promise(function (resolve, reject) {
        try {
            // nodes file
            var file_name_nodes = &#x27;csv-nodes-&#x27; + time_stamp + &#x27;.csv&#x27;;
            var file_path_nodes = path.join(Export.to_folder, file_name_nodes);
            var wstream_nodes = fs.createWriteStream(file_path_nodes);

            // relations file
            var file_name_relations = &#x27;csv-relations-&#x27; + time_stamp + &#x27;.csv&#x27;;
            var file_path_relations = path.join(Export.to_folder, file_name_relations);
            var wstream_relations = fs.createWriteStream(file_path_relations);

            // relationprops file
            var file_name_relationprops = &#x27;csv-relationprops-&#x27; + time_stamp + &#x27;.csv&#x27;;
            var file_path_relationprops = path.join(Export.to_folder, file_name_relationprops);
            var wstream_relationprops = fs.createWriteStream(file_path_relationprops);

            // nodeprops file
            var file_name_nodeprops = &#x27;csv-nodeprops-&#x27; + time_stamp + &#x27;.csv&#x27;;
            var file_path_nodeprops = path.join(Export.to_folder, file_name_nodeprops);
            var wstream_nodeprops = fs.createWriteStream(file_path_nodeprops);

            return Export._nodes_to_csv(wstream_nodes).then(function (data) {
                wstream_nodes.end();
                return Export._relations_to_csv(wstream_relations).then(function (data) {
                    wstream_relations.end();
                    return Export._relation_properties_to_csv(wstream_relationprops).then(function (data) {
                        wstream_relationprops.end();
                        return Export._node_properties_to_csv(wstream_nodeprops).then(function(data){
                            wstream_nodeprops.end();

                            var output_path = path.join(Export.to_folder, time_stamp+&#x27;.zip&#x27;)

                            var output = fs.createWriteStream(output_path);
                            var archive = archiver(&#x27;zip&#x27;, {
                                gzip: true,
                                zlib: { level: 9 }
                            });

                            archive.on(&#x27;error&#x27;, function(err) {
                              return reject(err);
                            });

                            // pipe archive data to the output file
                            archive.pipe(output);

                            // append files
                            [file_path_nodes, file_path_relations, file_path_relationprops, file_path_nodeprops].forEach(function(file_path){
                                archive.file(file_path, {name: path.basename(file_path)});
                            });
                            // finalize
                            archive.finalize();

                            output.on(&quot;close&quot;, function(){
                                [file_path_nodes, file_path_relations, file_path_relationprops, file_path_nodeprops].forEach(function(file_path){
                                    fs.unlinkSync(file_path);
                                });
                                resolve(output_path);
                            });
                        }).catch(function(err){
                            wstream_nodeprops.end();
                            reject(err);
                        });

                    }).catch(function (err) {
                        wstream_relationprops.end();
                        reject(err);
                    });

                }).catch(function (err) {
                    wstream_relations.end();
                    reject(err);
                });
            }).catch(function (err) {
                wstream_nodes.end();
                reject(err);
            });
        } catch (e) {
            reject(e);
        }
    });
};

module.exports = Export;
    </pre>
</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>
<script src="../assets/js/yui-prettify.js"></script>
<script src="../assets/../api.js"></script>
<script src="../assets/js/api-filter.js"></script>
<script src="../assets/js/api-list.js"></script>
<script src="../assets/js/api-search.js"></script>
<script src="../assets/js/apidocs.js"></script>
</body>
</html>
